package com.lunar.service.impl;

import com.lunar.entity.PlateInfo;
import com.lunar.entity.PostInfo;
import com.lunar.mapper.PlateInfoMapper;
import com.lunar.mapper.PostInfoMapper;
import com.lunar.service.PlateInfoService;
import com.lunar.service.PostInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PostInfoServiceImpl implements PostInfoService {

    @Autowired
    private PlateInfoMapper plateInfoMapper;

    @Autowired
    private PostInfoMapper postInfoMapper;

    @Override
    public List<PostInfo> getAll() {
        List<PostInfo> postInfos = postInfoMapper.selectAll();
        for (PostInfo postInfo : postInfos) {
            PlateInfo a = plateInfoMapper.selectByPrimaryKey(postInfo.getPubId());
            postInfo.setPublisherName(a.getPublisherName());
        }
        return postInfos;
    }

    @Override
    public int update(PostInfo postInfo) {
        return postInfoMapper.updateByPrimaryKey(postInfo);
    }
}
